
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2272. -- [Usaco2011 Feb]Cowlphabet  -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2272: [Usaco2011 Feb]Cowlphabet </h2><span class=green>Time Limit: </span>10 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>71&nbsp;&nbsp;<span class=green>Solved: </span>54<br>[<a href='submitpage.php?id=2272'>Submit</a>][<a href='problemstatus.php?id=2272'>Status</a>][<a href='bbs.php?id=2272'>Discuss</a>]</center><h2>Description</h2><div class=content><p><br />
Like all bovines, Farmer John's cows speak the peculiar 'Cow'<br />
language. Like so many languages, each word in this language comprises<br />
a sequence of upper and lowercase letters (A-Z and a-z).&nbsp; A word<br />
is valid if and only if each ordered pair of adjacent letters in<br />
the word is a valid pair.<br />
<br />
Farmer John, ever worried that his cows are plotting against him,<br />
recently tried to eavesdrop on their conversation. He overheard one<br />
word before the cows noticed his presence. The Cow language is<br />
spoken so quickly, and its sounds are so strange, that all that<br />
Farmer John was able to perceive was the total number of uppercase<br />
letters, U (1 &lt;= U &lt;= 250) and the total number of lowercase<br />
letters, L (1 &lt;= L &lt;= 250) in the word.<br />
<br />
Farmer John knows all P (1 &lt;= P &lt;= 200) valid ordered pairs of<br />
adjacent letters.&nbsp; He wishes to know how many different valid<br />
words are consistent with his limited data.&nbsp; However, since<br />
this number may be very large, he only needs the value modulo<br />
97654321.<br />
<br />
给出p对可用字母组合，要求组成一个由u个大写字母和l个小写字母组成的字符串，使字符串中任意一对 连续的字母都是p对之中的。问总方案数除以97654321的余数。<br />
</p></div><h2>Input</h2><div class=content><p><br />
* Line 1: Three space-separated integers: U, L and P<br />
<br />
* Lines 2..P+1: Two letters (each of which may be uppercase or<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lowercase), representing one valid ordered pair of adjacent<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; letters in Cow.<br />
<br />
</p></div><h2>Output</h2><div class=content><p><br />
* Line 1: A single integer, the number of valid words consistent with<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Farmer&nbsp; John's data mod 97654321.<br />
</p></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>2 2 7<br />
AB<br />
ab<br />
BA<br />
ba<br />
Aa<br />
Bb<br />
bB<br />
<br />
INPUT DETAILS:<br />
<br />
The word Farmer John overheard had 2 uppercase and 2 lowercase<br />
letters.  The valid pairs of adjacent letters are AB, ab, BA, ba,<br />
Aa, Bb and bB.<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>7<br />
<br />
OUTPUT DETAILS:<br />
<br />
The possible words are:<br />
AabB<br />
ABba<br />
abBA<br />
BAab<br />
BbBb<br />
bBAa<br />
bBbB<br />
<br />
</span></div><h2>HINT</h2>
			<div class=content><p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Gold'>Gold</a></p></div><center>[<a href='submitpage.php?id=2272'>Submit</a>][<a href='problemstatus.php?id=2272'>Status</a>][<a href='bbs.php?id=2272'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
